package com.pro.controller;

import com.pro.pojo.JsLoginRecord;
import com.pro.pojo.JsonData;
import com.pro.service.JsLoginRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 李佳豪
 * @date 2022/1/18 14:49
 * 用户登录日志
 */
@RestController
@RequestMapping("/JsLoginRecord")
public class JsLoginRecordController {
    @Autowired
    JsLoginRecordService jsLoginRecordService;
    @RequestMapping(value = "/getAllJsLoginRecord")
    public JsonData getAllJsLoginRecord(){
        List<JsLoginRecord> allJsLoginRecord = jsLoginRecordService.getAllJsLoginRecord();
        return allJsLoginRecord!=null ? JsonData.buildSuccess(allJsLoginRecord):JsonData.buildError("服务器错误");
    }

    /**
     * @Author 祖铭泽
     * @Date 2022/1/20/0020
     * @description 查询用户最后一次登陆时间
     */
    @RequestMapping(value = "/getLastLoginTimeByUserId")
    public JsonData getLastLoginTimeByUserId(Integer userId) {
        return jsLoginRecordService.getLastLoginTimeByUserId(userId);
    }
}
